import re,os


srt_content = open('D:\BaiduNetdiskDownload\请君入我怀\字幕\第1集.srt','r',encoding='utf_8_sig').read()
# 去除 SRT 文件中的时间戳和编号，仅保留对白文本
cleaned_lines = []
for line in srt_content:
    if not re.match(r"^\d+$", line.strip()) and not re.match(r"^\d{2}:\d{2}:\d{2},\d{3} --> \d{2}:\d{2}:\d{2},\d{3}$", line.strip()):
        cleaned_lines.append(line.strip())

# 组合成完整的对白文本
cleaned_script = "".join([line for line in cleaned_lines if line])
cleaned_script = cleaned_script.replace('::,-->::','')

# 输出部分整理后的对白内容
open('D:\BaiduNetdiskDownload\请君入我怀\字幕\第1集.txt','w',encoding='utf_8_sig').write(cleaned_script)

